package com.tbit.uqbike.object.pojo.vo;

import cn.hutool.core.collection.CollectionUtil;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.collections4.CollectionUtils;

import java.util.LinkedList;
import java.util.List;

/**
 * 批量操作成功或者异常信息返回实体类
 *
 * @Author:BUGTian
 * @DATE: 2022/10/11
 */
@Data
@Accessors(chain = true)
public class BatchOperationMsgVO<T> {
    /**
     * 成功列表
     */
    private List<T> successList;
    /**
     * 异常列表
     */
    private List<T> abnormalList;
    /**
     * 失败列表
     */
    private List<T> failList;

    /**
     * 不存在的列表
     * */
    private List<T> noExitList;

    public BatchOperationMsgVO() {
        this.successList = new LinkedList<>();
        this.abnormalList = new LinkedList<>();
        this.failList = new LinkedList<>();
        this.noExitList = new LinkedList<>();
    }

    public void putSuccessValue(T value) {
        if (value == null) {
            return;
        }
        this.successList.add(value);
    }

    public void  putAllSuccessValue(List<T> value) {
        if (CollectionUtil.isEmpty(value)) {
            return;
        }
        this.successList.addAll(value);
    }

    public void putAbnormalValue(T value) {
        if (value == null) {
            return;
        }
        this.abnormalList.add(value);
    }

    public void putAllAbnormalValue(List<T> value) {
        if (CollectionUtil.isEmpty(value)) {
            return;
        }
        this.abnormalList.addAll(value);
    }

    public void putFailValue(T value) {
        if (value == null) {
            return;
        }
        this.failList.add(value);
    }

    public void putAllFailValue(List<T> value) {
        if (CollectionUtil.isEmpty(value)) {
            return;
        }
        this.failList.addAll(value);
    }

    public void putNoExitValue(List<T> value){
        if (CollectionUtils.isEmpty(value)){
            return;
        }
        this.noExitList.addAll(value);
    }

    public static <T> BatchOperationMsgVO<T> empty() {
        return new BatchOperationMsgVO<>();
    }


}
